<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/layout/contentLayout.xhtml">

	<ui:param name="param_pageTitle"
		value="#{messages.luyuan_crm_menu_order}" />

	<ui:define name="road">
		<span>新增配方</span>
	</ui:define>

	<!-- content -->
	<ui:define name="content">
		<rg:areaPanel>
			<h:form>
				<rg:titlePanel id="formulaDetailTP" headerTitle="配方信息">
					<h:panelGroup id="formulaDetail">
						<rg:fieldSet column="one" >
		                    <rg:inputText id="formulaName" label="配方名称" value="#{addFormulaAction.formula.name}" required="true" textStyle="width:450px;" max="64" validateRule="length"/>
		                    <rg:selectOne id="productType" label="产品类型" value="#{addFormulaAction.formula.productType}" required="true"
								itemsProvider="#{productTypeProvider}" converter="#{productTypeConverter}" style="width:100px;"/>
		                    <rg:inputArea id="beforeBreakfast" label="临早餐前" value="#{addFormulaAction.formula.beforeBreakfast}" textStyle="width:450px;" max="256" validateRule="length"/>
		                    <rg:inputArea id="afterBreakfast" label="早餐后" value="#{addFormulaAction.formula.afterBreakfast}" textStyle="width:450px;" max="256" validateRule="length"/>
		                    <rg:inputArea id="beforeLunch" label="临午餐前" value="#{addFormulaAction.formula.beforeLunch}" textStyle="width:450px;" max="256" validateRule="length"/>
		                    <rg:inputArea id="afterLunch" label="午餐后" value="#{addFormulaAction.formula.afterLunch}" textStyle="width:450px;" max="256" validateRule="length"/>
		                    <rg:inputArea id="beforeDinner" label="临晚餐前" value="#{addFormulaAction.formula.beforeDinner}" textStyle="width:450px;" max="256" validateRule="length"/>
		                    <rg:inputArea id="afterDinner" label="晚餐后" value="#{addFormulaAction.formula.afterDinner}" textStyle="width:450px;" max="256" validateRule="length"/>
		                    <rg:inputArea id="beforeSleep" label="临睡前" value="#{addFormulaAction.formula.beforeSleep}" textStyle="width:450px;" max="256" validateRule="length"/>
							<rg:inputArea id="oldDrugBill" label="顾客原服用药单" value="#{addFormulaAction.formula.oldDrugBill}" textStyle="width:450px;" max="256" validateRule="length"/>
							<rg:inputArea id="customerRequire" label="顾客保健要求" value="#{addFormulaAction.formula.customerRequire}" textStyle="width:450px;"  max="256" validateRule="length"/>
							<rg:inputArea id="purpose" label="本配方保健目的" value="#{addFormulaAction.formula.purpose}" textStyle="width:450px;" max="256" validateRule="length"/>
							<rg:inputArea id="lifeNote" label="生活注意事项" value="#{addFormulaAction.formula.lifeNote}" textStyle="width:450px;" max="512" validateRule="length"/>
							<rg:inputArea id="remarks" label="备注" value="#{addFormulaAction.formula.remarks}" required="true" textStyle="width:450px;" max="256" validateRule="length"/>
							<rg:inputArea id="note" label="注" value="#{addFormulaAction.formula.note}" required="true" textStyle="width:450px;" max="512" validateRule="length"/>
							<rg:inputText id="price" label="原价" value="#{addFormulaAction.formula.price}" required="true" textStyle="width:450px;" max="256" validateRule="length"/>
							<rg:inputText id="specialPrice" label="特价" value="#{addFormulaAction.formula.specialPrice}" required="true" textStyle="width:450px;" max="256" validateRule="length"/>
						</rg:fieldSet>
					</h:panelGroup>
				</rg:titlePanel>
			
				<rg:titlePanel id="productsTP" headerTitle="保健清单">
					<ui:define name="headerActions">
						<h:outputLink value="#" onclick="UI.instance.showDialog({id:'updateFormula', src:'/luyuan/formula/addInventory.jsf'});return false;">增加</h:outputLink>
					</ui:define>
					<rg:table tableId="inventoryTable" value="#{addFormulaAction.products}" var="item" pagination="disable" pageSize="1">
						<rg:column property="product.name" title="产品名称"  width="100" height="100"/>
						<rg:column property="product.specification" title="产品规格"  width="100"/>
						<rg:column property="product.price" title="产品价格"  width="100"/>
						<rg:column property="quantity" title="产品数量"  width="100"/>
						<rg:column property="gift" title="是否赠品" converter="#{booleanConverter}"/>
						<rg:column title="#{messages.luyuan_crm_operator}">
							<ul class="links">
								<li>
									<a:commandLink value="#{messages.luyuan_crm_delete}" reRender="inventoryTable"
									action="#{addFormulaAction.deleteInventory(item.product.id)}" />
								</li>
							</ul>
						</rg:column>
					</rg:table>
					
				</rg:titlePanel>
				<div class="panelButton">
					<h:commandButton styleClass="button larger" value="新增" action="/luyuan/formula/listFormula.jsf" actionListener="#{addFormulaAction.addFormula()}" />
					<h:commandButton styleClass="button larger" value="返回" action="/luyuan/formula/listFormula.jsf" immediate="true"/>
				</div>
			</h:form>
			
			<a:form>
				<a:jsFunction name="reRenderInventoryTable" reRender="inventoryTable"/>
			</a:form>
		</rg:areaPanel>
	</ui:define>
</ui:composition>